<script lang="ts" setup name="test">
// 组件的使用方式
// <XtxBread parentPath="/category/1005000" parentName="电器">空调</XtxBread>
// <XtxBread>空调</XtxBread>

defineProps({
  parentName: {
    type: String,
    default: ''
  },
  parentPath: {
    type: String,
    default: ''
  }
})
</script>

<template>
  <div class="xtx-bread">
    <div class="xtx-bread-item">
      <RouterLink to="/">首页</RouterLink>
    </div>
    <i class="iconfont icon-angle-right"></i>
    <div class="xtx-bread-item">
      <RouterLink v-if="parentPath" :to="parentPath">{{ parentName }}</RouterLink>
      <span v-else>{{ parentName }}</span>
    </div>
    <i v-if="parentName" class="iconfont icon-angle-right"></i>
    <div class="xtx-bread-item">
      <span><slot /></span>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.xtx-bread {
  display: flex;
  padding: 25px 10px;
  &-item {
    a {
      color: #666;
      transition: all 0.4s;
      &:hover {
        color: $xtxColor;
      }
    }
  }
  i {
    font-size: 12px;
    margin-left: 5px;
    margin-right: 5px;
    line-height: 22px;
  }
}
</style>
